package com.itboye.mengwu.app.ui.aiwujia;

import java.util.ArrayList;
import java.util.List;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.TextView;

import com.itboye.core.object.BaseFragment;
import com.itboye.mengwu.R;

public class FragementGoods extends BaseFragment implements OnItemClickListener {

	private GridView goods_list_gv;
	ImageView goods_list_image;
	TextView goods_list_goodstv;
	TextView new_price;
	TextView old_price;
	TextView price_rebate;

	@Override
	public int initView() {

		return R.layout.goods_list;
	}

	@Override
	public void onMyActivityCreated() {
		Log.e("put", ">>>?");
		goods_list_gv = (GridView) getActivity().findViewById(
				R.id.goods_list_gv);
		MyAdapter adapter = new MyAdapter(getActivity(),
				R.layout.goods_list);
		goods_list_gv.setAdapter(adapter);
		goods_list_gv.setOnItemClickListener(this);

	}

	class MyAdapter extends BaseAdapter {
		Context context;
		int resID;

		public MyAdapter(Context context, int resID) {
			this.context = context;
			this.resID = resID;
		}

		@Override
		public int getCount() {
			return 5;
		}

		@Override
		public Object getItem(int position) {
			return position;
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			if (convertView == null) {
				convertView = CreateView();

			}
			goods_list_goodstv = (TextView) convertView
					.findViewById(R.id.goods_list_goodstv);
			goods_list_image = (ImageView) convertView
					.findViewById(R.id.goods_list_image);
			goods_list_image.setScaleType(ScaleType.CENTER_CROP);
			com.nostra13.universalimageloader.core.ImageLoader
					.getInstance()
					.displayImage(
							"http://img1.moko.cc/users/2/745/223733/post/5c/img1_src_3470923.jpg?imageView2/2/w/915/h/915",
							goods_list_image);
			goods_list_goodstv.setText("假日套装");
			return convertView;
		}

		@SuppressLint("InflateParams")
		private View CreateView() {
			View v = null;

			LayoutInflater inflater = LayoutInflater.from(context);
			v = inflater.inflate(R.layout.goods_list_item, null);

			return v;
		}

	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id) {
		Intent intent = new Intent(getActivity(), DetailCommentActivity.class);
		startActivity(intent);

	}

}
